package com.lib.controller.adminapi;

import com.alibaba.fastjson.JSONObject;
import com.lib.application.ShopQRCodeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * Created by duqingxiang on 17/5/24.
 */
@RestController
@RequestMapping("/admin/api/shop")
public class ShopQRCodeApiController {

    @Autowired
    ShopQRCodeService shopQRCodeService;

    @RequestMapping("/createShopQRCode")
    public String createShopQRCode(@RequestParam Long shopId
                        ,@RequestParam String shopName){


        String ticket = shopQRCodeService.saveShopQRCode(shopId,shopName);

        JSONObject result = new JSONObject();
        result.put("ticket",ticket);
        return result.toJSONString();
    }

    @RequestMapping("/getShopQRCode")
    public String getShopQRCode(@RequestParam Long shopId){
        String ticket = shopQRCodeService.getShopQRCode(shopId);

        JSONObject result = new JSONObject();
        result.put("ticket",ticket);
        return result.toJSONString();
    }

}
